package com.situ.science.controller;

import com.situ.science.pojo.Contest;
import com.situ.science.pojo.charts.ContestNum;
import com.situ.science.pojo.query.ContestQuery;
import com.situ.science.pojo.vo.ProjectVo;
import com.situ.science.service.IContestService;
import com.situ.science.utils.PageRusults;
import com.situ.science.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/contest")
public class ContestController {
    @Autowired
    private IContestService contestService;
    @GetMapping("/list")
    public Result list() {//getContests
        System.out.println("ContestController.list");
        List<Contest> contestList = contestService.list();
        return Result.ok(contestList);
    }
    @RequestMapping("/selectByPage")
    public Result selectByPage(ContestQuery contestQuery) {
        System.out.println("ContestController.selectByPage");
        PageRusults pageRusults = contestService.selectByPage(contestQuery);
        return Result.ok(pageRusults);
    }
    @RequestMapping("/add")
    public Result add(@RequestBody Contest contest) {
        System.out.println("ContestController.add");
        System.out.println("contest:"+contest);
        contestService.add(contest);
        return Result.ok("添加成功");
    }
    @RequestMapping("/contestNum")
    public Result contestNum() {
        System.out.println("ContestController.contestNum");
        List<ContestNum> contestNum = contestService.contestNum();
        return Result.ok(contestNum);
    }
    @RequestMapping("/getById/{id}")
    public Result getById(@PathVariable Integer id) {
        System.out.println("ContestController.getById");
        Contest contest = contestService.getById(id);
        return Result.ok(contest);
    }
}
